Elastic
04/02/2025, 11:06 AMVapi Support Bot
04/02/2025, 11:08 AM</body>
tag:
html
<script>
var vapiInstance = null;
const assistant = "<assistant_id>"; // Substitute with your assistant ID
const apiKey = "<your_public_api_key>"; // Substitute with your Public key from Vapi Dashboard
const buttonConfig = {}; // Modify this as required
(function (d, t) {
var g = document.createElement(t),
s = d.getElementsByTagName(t)[0];
g.src =
"https://cdn.jsdelivr.net/gh/VapiAI/html-script-tag@latest/dist/assets/index.js";
g.defer = true;
g.async = true;
s.parentNode.insertBefore(g, s);
g.onload = function () {
vapiInstance = window.vapiSDK.run({
apiKey: apiKey, // mandatory
assistant: assistant, // mandatory
config: buttonConfig, // optional
});
};
})(document, "script");
</script>
Remember to replace <assistant_id>
with your actual assistant ID and <your_public_api_key>
with your public API key from the [Vapi Dashboard](https://docs.vapi.ai/examples/voice-widget).
## Placing the Widget in a Specific Location
If you want to place the widget in a specific location on your page, you can append it to a custom element:
html
<div id="Call"></div>
<script>
// Same script as above
</script>
This will attach the Vapi widget to the div with ID "Call" instead of the default location ([source](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336696033366773800)).
## Customizing the AppearanceVapi Support Bot
04/02/2025, 11:08 AMcss
<style>
.vapi-btn {
z-index: 1000 !important;
}
</style>
You can also change the default green circle to a custom image by modifying the styling ([source](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336007021308149861)).
## Triggering Conversations with Custom Icons
To use your own icon or image to trigger the conversation, you can create a button with an onClick event handler:
html
<button id="start-conversation" onClick="startConversation()">
<img src="your-icon.png" alt="Start Conversation" />
</button>
<script>
function startConversation() {
// Function to start the conversation
vapi.send({
type: "add-message",
message: {
role: "system",
content: "The user has clicked to start a conversation",
},
});
}
</script>
The vapi.send
function is the primary way to interact with your assistant ([source](https://docs.vapi.ai/assistants/background-messages)).
Is there anything specific about the embedding process you'd like me to explain further?
Sources:
- [Vapi Voice Widget Documentation](https://docs.vapi.ai/examples/voice-widget)
- [Discord Thread on Custom Element Embedding](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336696033366773800)
- [Discord Thread on Customizing Appearance](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336007021308149861)
- [Background Messages Documentation](https://docs.vapi.ai/assistants/background-messages)Vapi Support Bot
04/02/2025, 11:19 AMKyle
04/02/2025, 1:07 PMElastic
04/02/2025, 2:20 PMElastic
04/03/2025, 4:45 PMKyle
04/07/2025, 4:20 PMElastic
04/07/2025, 9:00 PMKyle
04/08/2025, 11:04 PMElastic
04/08/2025, 11:12 PMElastic
04/08/2025, 11:14 PMElastic
04/08/2025, 11:15 PMKyle
04/10/2025, 10:50 PMKyle
04/10/2025, 10:51 PM